#include<bits/stdc++.h>
using namespace std;
const int mx=1000005;
int T;
int n,m,L,V;
int d[mx],v[mx],a[mx];
bool p[mx];
int cnt=0;

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        int k;
        for(int i=1;i<=m;i++){
            cin>>k;
            p[k]=1;
        }
        //in over
        for(int i=1;i<=n;i++){
            if(v[i]>V){
                cnt++;
            }
        }
    }
    cout<<cnt<<" "<<1<<endl;
    fclose(stdin);
    fclose(stdout);
    return 0;
}
